package pen_exam.yongyou_2020_10_26;

import java.util.Arrays;

public class Class01_SortGrade {
    public class Node{
        String name;
        int score;

        public Node(String name, int score) {
            this.name = name;
            this.score = score;
        }
    }
    public String[] sortPeople (String[] names, int[] scores) {
        // write code here
        int N = names.length;
        Node[] nodes = new Node[N];
        for (int i = 0; i < N; i++) {
            nodes[i] = new Node(names[i],scores[i]);
        }
        Arrays.sort(nodes,(n1,n2) ->{ return n2.score - n1.score;
        });
        String[] res = new String[N];
        for (int i = 0; i < N; i++) {
            res[i] = nodes[i].name;
        }
        return res;
    }
}
